import {UserBeanUtils, ajaxAsync} from 'vue-xiaobu-utils'

/**
 * 未读消息的获取
 */
async function getMessage() {
  if (UserBeanUtils.isUserLogin()) {
    try {
      let res = await ajaxAsync('/user/message/unread_count', {}, 2)
      return res.COUNT
    } catch (err) {
      // let code = err.error.response.status
      // if (code === 403) return 0
      // 所有的异常状态都返回数量0
      return 0
    }
  } else {
    return 0
  }
}

export { getMessage }
